Learn R Programming

cherry (version 0.6-14)

Closure class: Class "closure" for storing the result of the closed testing procedure

Description

The class closure is the output of a call to closed. It stores the information needed to calculate confidence sets for the number of true and/or false hypotheses among a selected set.

Arguments

Slots

These slots are not meant to be directly accessed by the user.

adjusted:

Object of class "numeric". Sores the adjusted p-values.

defining:

Object of class "integer". Stores the identifiers of the intersection hypotheses that are the defining rejections of the closed testing procedure. The identifiers should be read as binary booleans, i.e. 19 = 10011 (binary) is the intersection of the first, second and fifth elementary hypothesis.

hypotheses:

Object of class "character". Holds the names of the elementary hypotheses.

alpha:

Object of class "numeric". The type I error level chosen.

max.alpha:

Object of class "numeric". The largest value for which adjusted p-values have been calculated.

Methods

show

(closure): Prints a brief description of the test results, including the upper bound of the number of true hypotheses and the corresponding lower bound to the number of false hypotheses among the full set.

summary

(closure): Prints the test results (as show) plus the defining rejections.

defining

(closure): Extracts the defining rejections as a list.

shortlist

(closure): Extracts the shortlist as a list.

hypotheses

(closure): Extracts the hypotheses slot.

See Also

closed, pick.

Examples

Run this code
# NOT RUN {
  # Example: the birthwt data set from the MASS library
  # We want to find variables associated with low birth weight
  library(MASS)
  fullfit <- glm(low~age+lwt+race+smoke+ptl+ht+ui+ftv, family=binomial, data=birthwt)
  hypotheses <- c("age", "lwt", "race", "smoke", "ptl", "ht", "ui", "ftv")

  # Define the local test to be used in the closed testing procedure
  mytest <- function(hyps) {
    others <- setdiff(hypotheses, hyps)
    form <- formula(paste(c("low~",  paste(c("1", others), collapse="+"))))
    anov <- anova(glm(form, data=birthwt, family=binomial), fullfit, test="Chisq")
    res <- anov$"Pr("[2]                    # for R >= 2.14.0
    if (is.null(res)) res <- anov$"P("[2]   # earlier versions
    res
  }

  # perform the closed testing procedure
  cl <- closed(mytest, hypotheses)
  summary(cl)
  defining(cl)
  shortlist(cl)
  hypotheses(cl)

  # how many variables among a chosen set are associated with the response?
  pick(cl, c("ht", "lwt", "smoke", "ui"))
# }

Run the code above in your browser using DataLab